package com.bishe.controller;


import com.bishe.entity.PersonnelInfo;
import com.bishe.entity.query.PersonnelInfoQuery;
import com.bishe.entity.response.R;
import com.bishe.service.PersonnelInfoService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
 * (PersonnelInfo)表控制层
 *
 * @author makejava
 * @since 2024-03-04 14:00:14
 */
@RestController
@RequestMapping("personnelInfo")
@Api(tags = "人员信息")
public class PersonnelInfoController{
    /**
     * 服务对象
     */
    @Resource
    private PersonnelInfoService personnelInfoService;


    @PostMapping("page")
    public R selectAll(@RequestBody PersonnelInfoQuery query) {
        return R.ok(this.personnelInfoService.getPage(query));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public R selectOne(@PathVariable Serializable id) {
        return R.ok(this.personnelInfoService.getById(id));
    }

    /**
     * 新增数据
     *
     * @param personnelInfo 实体对象
     * @return 新增结果
     */
    @PostMapping
    public R insert(@RequestBody PersonnelInfo personnelInfo) {
        return R.ok(this.personnelInfoService.save(personnelInfo));
    }

    /**
     * 修改数据
     *
     * @param personnelInfo 实体对象
     * @return 修改结果
     */
    @PutMapping
    public R update(@RequestBody PersonnelInfo personnelInfo) {
        return R.ok(this.personnelInfoService.updateById(personnelInfo));
    }

    /**
     * 删除数据
     *
     * @param idList 主键结合
     * @return 删除结果
     */
    @DeleteMapping
    public R delete(@RequestBody List<String> idList) {
        return R.ok(this.personnelInfoService.removeByIds(idList));
    }
}

